var Tday = new Array();
var daysms = 24 * 60 * 60 * 1000;
var hoursms = 60 * 60 * 1000;
var Secondms = 60 * 1000;
var microsecond = 1000;
var DifferHour = -1;
var DifferMinute = -1;
var DifferSecond = -1;
function clock(key)
{
  var end_time = document.getElementById('end_time'+key).value;
  var Tdays = end_time * 1000;
  var time = new Date();
  var hour = time.getHours();
  var minute = time.getMinutes();
  var second = time.getSeconds();
  var timevalue = ""+((hour > 12) ?hour-12:hour);
  timevalue +=((minute < 10) ? ":0":":")+minute;
  timevalue +=((second < 10) ? ":0":":")+second;
  timevalue +=((hour > 12 ) ? " PM":" AM");
  var convertHour = DifferHour;
  var convertMinute = DifferMinute;
  var convertSecond = DifferSecond;
  var Diffms = Tdays - time.getTime();
  if (Diffms < 0) 
  {
    window.location.reload();//重新刷新页面
  }
  DifferHour = Math.floor(Diffms / daysms);
  Diffms -= DifferHour * daysms;
  DifferMinute = Math.floor(Diffms / hoursms);
  Diffms -= DifferMinute * hoursms;
  DifferSecond = Math.floor(Diffms / Secondms);
  Diffms -= DifferSecond * Secondms;
  var dSecs = Math.floor(Diffms / microsecond);


  if(convertHour != DifferHour) a="<span>"+DifferHour+"</span>天";
  if(convertMinute != DifferMinute) b="<span>"+DifferMinute+"</span>时";
  if(convertSecond != DifferSecond) c="<span>"+DifferSecond+"</span>分";
  d="<span>"+dSecs+"</span>秒";
  if (DifferHour>0) 
  {
    a=a;
  }
  else 
  {
    a='';
  }
  if (DifferMinute>0) 
  {
    b=b;
  }
  else 
  {
    b='';
  }
  if (DifferSecond>0) 
  {
    c=c;
  }
  else 
  {
    c='';
  }
  if (DifferHour == 0 && DifferMinute == 0 && DifferSecond == 0 && dSecs==1) {
    window.location.reload();//重新刷新页面
  }

  document.getElementById("leftTime"+key).innerHTML = a + b + c +d; //显示倒计时信息

}